package com.xxxx.car.flow.vo;

import com.xxxx.car.common.exception.ServiceException;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.constraints.NotNull;
import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class BpmnInfoVo implements Serializable {

    @NotNull(message = "请选择流程类型")
    private Long bpmnType;

    @NotNull(message = "请选择部署信息")
    private String info;

    @NotNull(message = "请选择流程文件")
    private MultipartFile bpmnFile;

    public InputStream getBpmnFileSteam(){
        try{
            return bpmnFile.getInputStream();
        }catch (IOException e){
            throw new ServiceException("获取流程文件输入流失败: " + e.getMessage());
        }
    }

    public String getBpmnFileName(){
        return bpmnFile.getOriginalFilename();
    }
}
